package com.qlslylq.ad.sdk.application;

import com.qlslylq.ad.sdk.enums.AdType;

import java.util.Set;

/**
 * 聚合SDK初始化用配置类<br/>
 */
public class AdMergeSDKConfig {

    //媒体ID(媒体方在本聚合平台上的应用ID)
    private long appId;

    //[true,false]表示[测试环境，正式环境]
    private boolean isTest;

    //[true,false]表示[开启调试日志，关闭调试日志]
    private boolean isDebug;

    //展示失败自动轮换子策略应用的广告类型，默认为null即全部开启，[]为全部不开启
    private Set<AdType> tryAgainAdTypes;

    private AdMergeSDKConfig(AdMergeSDKConfig.Builder builder) {
        this.appId = builder.appId;
        this.isTest = builder.isTest;
        this.isDebug = builder.isDebug;
        this.tryAgainAdTypes = builder.tryAgainAdTypes;
    }

    public long getAppId() {
        return appId;
    }

    public boolean isTest() {
        return isTest;
    }

    public boolean isDebug() {
        return isDebug;
    }

    public Set<AdType> getTryAgainAdTypes() {
        return tryAgainAdTypes;
    }

    public static class Builder {

        //必填
        private long appId;

        //默认环境：测试线
        private boolean isTest = true;

        //默认调试模式：开启
        private boolean isDebug = true;

        //展示失败自动轮换子策略应用的广告类型，默认为null即全部开启，[]为全部不开启
        private Set<AdType> tryAgainAdTypes = null;

        public AdMergeSDKConfig.Builder setAppId(long appId) {
            this.appId = appId;
            return this;
        }

        public AdMergeSDKConfig.Builder setTest(boolean isTest) {
            this.isTest = isTest;
            return this;
        }

        public AdMergeSDKConfig.Builder setDebug(boolean isDebug) {
            this.isDebug = isDebug;
            return this;
        }

        public AdMergeSDKConfig.Builder setTryAgainAdTypes(Set<AdType> tryAgainAdTypes) {
            this.tryAgainAdTypes = tryAgainAdTypes;
            return this;
        }

        public AdMergeSDKConfig build() {
            if (this.appId == 0) {
                throw new RuntimeException("appId错误");
            } else {
                return new AdMergeSDKConfig(this);
            }
        }
    }
}
